<template>
    <div>
        <el-card shadow="always" :body-style="{ padding: '20px' }">
            <el-form :inline="true" class="demo-form-inline">
                <el-form-item label="一级分类">
                    <el-select placeholder="请选择" v-model="categoryStore.c1Id" @change="c1Handler" :disabled="show!=0">
                        <el-option :label="c1.name" :value="c1.id" v-for="(c1,index) in categoryStore.c1List" :key="c1.id" />
                    </el-select>
                </el-form-item>
                <el-form-item label="二级分类">
                    <el-select placeholder="请选择" v-model="categoryStore.c2Id" @change="c2Handler" :disabled="show!=0">
                        <el-option :label="c2.name" :value="c2.id" v-for="(c2,index) in categoryStore.c2List" :key="c2.id" />
                    </el-select>
                </el-form-item>
                <el-form-item label="三级分类">
                    <el-select placeholder="请选择" v-model="categoryStore.c3Id" :disabled="show!=0">
                        <el-option :label="c3.name" :value="c3.id" v-for="(c3,index) in categoryStore.c3List" :key="c3.id" />
                    </el-select>
                </el-form-item>
            </el-form>
        </el-card>

    </div>
</template>

<script setup lang="ts">
import useCategoryStore from '@/stores/category'
import { onMounted } from 'vue';
let categoryStore = useCategoryStore()
// 组件挂载
onMounted(() => {
    // 获取一级分类
    categoryStore.getC1List()
});
// 获取二级分类
const c1Handler = () =>{
    categoryStore.getC2List()
}

// 获取三级分类
const c2Handler = () =>{
    categoryStore.getC3List()
}

defineProps(['show'])
</script>

<style scoped>

</style>